/*
 * @Author: FengShan
 * @Date: 2025-07-07 17:11:50
 * @LastEditors: asanupup 15465106+asanupup@user.noreply.gitee.com
 * @LastEditTime: 2025-07-22 09:20:21
 * @Description: 统计数据
 * 
 * Copyright (c) 2025 by FengShan, All Rights Reserved. 
 */

import { Controller, Get, Post, Body, Patch, Param, Delete, Req, UseGuards, Query } from '@nestjs/common';
import { StatisticsService } from './statistics.service';
import { Public } from 'src/decorations/public.decorator';
import { RoleGuard } from 'src/guards/role.guard';
import { Roles } from 'src/decorations/role.decorator';
import { IpAddress } from 'src/decorations/IpAddress.decorations';


@Controller('statistics')
@UseGuards(RoleGuard)
export class StatisticsController {
  constructor(private readonly statisticsService: StatisticsService) { }

  @Post('queryDayData')
  async queryDayData(@Body() body) {
    return this.statisticsService.queryDayData(body);
  }

  @Get('reviewStatistic')
  getReviewStatistic(@Query() query) {
    return this.statisticsService.getReviewStatistic(+query.type,query.date)
  }

  @Get('queryStatistic')
  getAwsStatistic(@Query() query) {
    return this.statisticsService.getAwsStatistic(+query.type, query.date)
  }

  @Public()
  @Get('index')
  create(@IpAddress() clientIp: string) {
    return this.statisticsService.create(clientIp);
  }

  @Delete('del:id')
  @Roles(['admin'])
  remove(@Param('id') id: string) {
    return this.statisticsService.remove(+id);
  }
}
